﻿using BigEgg.Framework.Foundation;
using BigEgg.Framework.UnitTesting;
using FMStudio.Domain.Properties;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Globalization;

namespace FMStudio.Domain.SQLite.Test
{
    [TestClass]
    public class CurrencyTest
    {
        [TestMethod]
        public void GeneralCurrencyTest()
        {
            Currency currency = new Currency();

            Assert.IsNotNull(currency.ID);
            Assert.AreEqual("", currency.Name);

            currency.Name = "RMB";

            Assert.AreEqual("", currency.Validate());
        }

        [TestMethod]
        public void CurrencyNameValidationTest()
        {
            Currency currency = new Currency();

            Assert.AreEqual(string.Empty, currency.Name);
            Assert.AreEqual(Resources.CurrencyNameMandatory, currency.Validate("Name"));

            currency.Name = TestHelper.CreateString('A', 3);
            Assert.AreEqual("", currency.Validate("Name"));
            currency.Name = TestHelper.CreateString('A', 2);
            Assert.AreEqual("", currency.Validate("Name"));
            currency.Name = TestHelper.CreateString('A', 4);
            Assert.AreEqual(
                string.Format(CultureInfo.CurrentCulture, Resources.CurrencyNameMaxLength, "Name", 3)
                , currency.Validate("Name"));
        }
    }
}
